<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  function people1(name){
    this.name = name;
  }

  function people2(name, p){
    this.name = name;
    this.p = p;
    this.send = function(msg){
      console.log(`你好${p.name}，这是${this.name}送你的${msg}`)
    }
  }

  function proxy(p){
    this.p = p;
    this.data = [];
    this.send = function(msg){
      const p2 = new people2("李四", p1);
      // 拦截数据
      // this.data.push(msg);
      // 记录数据
      this.data.push({
        x: this.p.name,
        y: p2.name,
        msg: msg,
        time: Date.now()
      });

      p2.send(msg);
    }
  }
  
  const p1 = new people1("张三");

  const pro = new proxy(p1);
  pro.send("手机");

  console.log(pro.data);


</script>
</html>